function OtherMusic() {
};

OtherMusic.instance = function() {
  var popupBox = new PopupBox(), popupBox2 = new PopupBox2(), _self = this;
  
  var model = Model.instance('{{$smarty.const.MODEL_NAME_MUSIC|escape:javascript}}', '{{$smarty.const.MODEL_TITLE_MUSIC|escape:javascript}}', '{{$smarty.const.MODEL_TYPE_ORDER|escape:javascript}}');
  
  //Create model here...
  var state1 = State.instance(model, 0, 'not activate (No Wedding Day)');
  var state2 = State.instance(model, 1, 'waiting video music');
  var state3 = State.instance(model, 2, 'upload video music');
  var state4 = State.instance(model, 3, 'video music ready');
  
  var transition1 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition2 = Transition.instance('rmd CUS', state2, state2, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.mixed, 14);
  var transition3 = Transition.instance('uploaded', state3, state4, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.none);
  
  var transition4 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition5 = Transition.instance('rmd CUS', state2, state2, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.mixed, 14);

  var transition6 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition7 = Transition.instance('rmd CUS', state2, state2, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.mixed, 14);
  var transition8 = Transition.instance('uploaded', state3, state4, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.none);
  
  var transition9 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 1);
  var transition10 = Transition.instance('rmd CUS', state2, state2, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.mixed, 14);
  var transition11 = Transition.instance('uploaded', state3, state4, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.none);
  
  transition2.validate = function(produce, user, date, options) { if (transition2.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  transition5.validate = function(produce, user, date, options) { if (transition5.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  transition7.validate = function(produce, user, date, options) { if (transition7.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  transition10.validate = function(produce, user, date, options) { if (transition10.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };

  transition1.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._method == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._method;
                                                                                                             produce.how = produce._method;
                                                                                                             DlmanageUtils.operate(transition1, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                    new DialogMethod(div, produce, null);
                                                                                  };
  
  transition3.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.branch = previous.branch;
                                                                                    options.orderDate = produce.date;
                                                                                    options.user = user;
                                                                                    options.date = date;
                                                                                    options.orderFlag = produce.orderFlag;
                                                                                    options.orderTrackId = produce.orderTrackId;
                                                                                    options.orderId = produce.orderId;
                                                                                    options.customerId = produce.customerId;
                                                                                    options._chgDeadline = true;
                                                                                    DlmanageUtils.operate2(transition3, pos, callbackFunc, produce, user, date, options);
                                                                                  };
  
  transition4.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  var div = document.createElement('div');
                                                                                  var func1 = function() { if (produce._method == '') {
                                                                                                             window.alert('CAN NOT BE EMPTY');
                                                                                                             return;
                                                                                                           }
                                                                                                           if (!options) {
                                                                                                             options = {};
                                                                                                           }
                                                                                                           options.extra = produce._method;
                                                                                                           produce.how = produce._method;
                                                                                                           DlmanageUtils.operate(transition4, pos, callbackFunc, produce, user, date, options);
                                                                                                           popupBox2._close();
                                                                                                         };
                                                                                  var func2 = function() { popupBox2._close();
                                                                                                           callbackFunc();
                                                                                                         };
                                                                                  MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                  new DialogMethod(div, produce, null);
                                                                                };
                                                                                
                                                                                
  transition6.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._method == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._method;
                                                                                                             produce.how = produce._method;
                                                                                                             DlmanageUtils.operate(transition6, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                    new DialogMethod(div, produce, null);
                                                                                  };

  transition8.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.branch = previous.branch;
                                                                                    options.orderDate = produce.date;
                                                                                    options.user = user;
                                                                                    options.date = date;
                                                                                    options.orderFlag = produce.orderFlag;
                                                                                    options.orderTrackId = produce.orderTrackId;
                                                                                    options.orderId = produce.orderId;
                                                                                    options.customerId = produce.customerId;
                                                                                    options._chgDeadline = true;
                                                                                    DlmanageUtils.operate2(transition8, pos, callbackFunc, produce, user, date, options);
                                                                                  };
transition9.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  var div = document.createElement('div');
                                                                                  var func1 = function() { if (produce._method == '') {
                                                                                                             window.alert('CAN NOT BE EMPTY');
                                                                                                             return;
                                                                                                           }
                                                                                                           if (!options) {
                                                                                                             options = {};
                                                                                                           }
                                                                                                           options.extra = produce._method;
                                                                                                           produce.how = produce._method;
                                                                                                           DlmanageUtils.operate(transition9, pos, callbackFunc, produce, user, date, options);
                                                                                                           popupBox2._close();
                                                                                                         };
                                                                                  var func2 = function() { popupBox2._close();
                                                                                                           callbackFunc();
                                                                                                         };
                                                                                  MiscUtils.dialog(popupBox2, pos, div, func1, func2, { t: 'Method', width: 520, height: 80, func: func2});
                                                                                  new DialogMethod(div, produce, null);
                                                                                };

transition11.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  options.branch = previous.branch;
                                                                                  options.orderDate = produce.date;
                                                                                  options.user = user;
                                                                                  options.date = date;
                                                                                  options.orderFlag = produce.orderFlag;
                                                                                  options.orderTrackId = produce.orderTrackId;
                                                                                  options.orderId = produce.orderId;
                                                                                  options.customerId = produce.customerId;
                                                                                  options._chgDeadline = true;
                                                                                  DlmanageUtils.operate2(transition11, pos, callbackFunc, produce, user, date, options);
                                                                                };

  model.states = [ state1, state2, state3, state4 ];
  model.transitions = [ transition1, transition2, transition3, transition4, transition5, transition6, transition7, transition8, transition9, transition10, transition11 ];
  return model;
};
